/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 * 
 *	Created on 2010-12-13 下午04:25:14
 */
package cn.com.ccxe.core.entity;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 更新级别
 * @author hetao
 * 
 * Updated on 2010-12-13 下午04:42:06
 */
public class UpdateLevel implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(UpdateLevel.class);
	public static final double UPDATE_MIN = 5;
	public static final double UPDATE_MAX = 30*24*60;
	public static final double UPDATE_DEFAULT = 15;
	
	/**
	 * 根据当前的更新时间
	 * @param i
	 * @param flag
	 * @return
	 */
	public static double computeUpdateTime(double i,boolean flag) {
		double tmp;
		if(flag) {
			tmp = i - (i * 0.5);
			return tmp > UPDATE_MIN ? (tmp > UPDATE_MAX ? UPDATE_MAX : tmp) : UPDATE_MIN;
		}else {
			tmp = i + (i * 0.5);
			return tmp > UPDATE_MAX ? UPDATE_MAX : (tmp > UPDATE_MIN ? tmp : UPDATE_MIN);
		}
	}
}
